import sqlite3

max_table = 1533
db_count = int(max_table / 100) + 1
conns = []


def get_connection(table_index):
    index = int(table_index / 100)
    return conns[index]


def commit_connections():
    for conn in conns:
        conn.commit()


for i in range(0, db_count):
    conn = sqlite3.connect('../database_{}.db'.format(i))
    conn.row_factory = sqlite3.Row
    conns.append(conn)
